package com.koron.css2.clientCenter.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.clientCenter.bean.UserStopBean;
import com.koron.css2.clientCenter.mapper.StopUserMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.util.Constant;
import com.koron.util.JsonUtils;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;
/**
 * 用户停用编辑
 * @author 甄玉晴
 *
 */
public class StopUserUpdate implements ServerInterface {

	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
		try {
			StopUserMapper mapper = factory.getMapper(StopUserMapper.class);
			UserStopBean bean = JsonUtils.objectToPojo(req.getData(), UserStopBean.class);
			// 获取停用信息
			bean.setUpdateInfo(userInfo);
			if(bean!=null && "".equals(bean.getReuseTimeLimit())) {
				bean.setReuseTimeLimit(null);
			}
			//记录停用信息
			mapper.userStopUpdate(bean);
			return MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "success", void.class);
		} catch (Exception e) {
			logger.error("用户停用编辑失败", e);
			return MessageBean.create(Constant.MESSAGE_INT_FAIL, "用户停用编辑失败", void.class);
		}
	}

}
